from selenium.webdriver.common.by import By

from base.page_base import PageBase


class PurchasePage(PageBase):
    """下单页面"""
    # 首页-->购物车
    __cart_btn = (By.XPATH, '//android.widget.TextView[@text="购物车"]')
    __settlement = (
        By.XPATH,
        '//androidx.compose.ui.platform.ComposeView/android.view.View/android.view.View/android.view.View[5]')
    __order = (By.ID, 'com.netease.yanxuan:id/order_btn')

    def click_cart_btn(self):
        """点击购物车按钮"""
        self.base_click(self.__cart_btn)

    def click_settlement(self):
        """点击结算按钮"""
        self.base_click(self.__settlement)

    def click_order(self):
        """点击提交按钮"""
        self.base_click(self.__order)

    def purchase(self):
        """下单业务"""
        self.click_cart_btn()
        self.click_settlement()
        self.click_order()
